package com.party.core.service.count.impl;

import com.google.common.base.Strings;
import com.party.core.model.goods.Goods;
import com.party.core.service.count.IModuleCountService;
import com.party.core.service.goods.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * 商品统计实现
 * Created by wei.li.
 *
 * @date 2017/12/22 0022
 * @time 11:32
 */

@Service
@Component(value = "goodsCountService")
public class GoodsCountService implements IModuleCountService {

    @Autowired
    private IGoodsService goodsService;

    /**
     * 增加商品浏览量
     * @param id 业务编号
     */
    @Override
    public void addViewNum(String id) {
        if (!Strings.isNullOrEmpty(id)){
            Goods goods = goodsService.get(id);
            if (null != goods){
                goods.setViewNum(goods.getViewNum() + 1);
                goodsService.update(goods);
            }
        }
    }
}
